import Phaser from 'phaser';

export default class Bullet extends Phaser.GameObjects.Sprite {
    constructor(scene){
        const {x, y} = scene.ship;

        super(scene, x, y-120, 'bullet');

        scene.add.existing(this);
        this.play('shoot');
        scene.physics.world.enableBody(this);
        this.body.velocity.y = -(250+scene.shipSpeed);

        this.scene.bullets.add(this);
    }

    update(){
        if(this.y<0){
            this.destroy();
        }
    }
}